package com.ExcelServer.handler;

import com.ExcelServer.common.Result;
import com.ExcelServer.exception.ChangeStatusException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    private final static Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);

    @ExceptionHandler(ChangeStatusException.class)
    public Result<?> handleJobNumberNotExistException(){
        return Result.fail(201,"更改审核状态失败",null);
    }

    //假装 只有默认出错的错误状态码为201
    @ExceptionHandler(value = RuntimeException.class)
    public Result<?> BaseException(RuntimeException e){
        e.printStackTrace();
        logger.error(e.getMessage());
        return Result.fail(e.getMessage());
    }

}
